package com.example.time;

import org.junit.Test;
import org.springframework.cglib.core.Local;

import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalField;

/**
 * 时间
 *
 * @author qingyan 2021-11-25
 */
public class ClockTest {

    @Test
    public void test(){

        Instant now = Instant.now();
        System.out.println(now);
        System.out.println(Clock.systemDefaultZone().instant()); // 2018-03-19T10:10:27.156Z
        System.out.println(Clock.systemDefaultZone().getZone()); // Europe/Moscow
        System.out.println(LocalDateTime.now());
        System.out.println(LocalDateTime.now());
        System.out.println(Instant.now().atZone(ZoneId.systemDefault()));
        System.out.println(Clock.systemDefaultZone().instant());
        System.out.println(ZoneId.systemDefault());
        System.out.println(System.currentTimeMillis());
        System.out.println(Instant.now().toEpochMilli());
        System.out.println(Clock.systemDefaultZone().millis());
        System.out.println(System.nanoTime());
        System.out.println(Duration.between(LocalDateTime.now(), LocalDateTime.now()).getNano());
        System.out.println(ZonedDateTime.now());
    }
    //1181+1700
    @Test
    public void test1(){
        System.out.println(Duration.between(LocalTime.parse("14:43:55"), LocalTime.parse("14:45:11")).getSeconds());
    }
}
